package com.yunzone.cloud.modules.payment.controller;


import com.yunzone.cloud.common.entity.Result;
import com.yunzone.cloud.modules.payment.entity.Payment;
import com.yunzone.cloud.modules.payment.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;


@RestController
@RequestMapping("/payment")
@Slf4j
public class PaymentController {
    @Resource
    private PaymentService paymentService;

    @Value("${server.port}")
    private String serverPort;


    @GetMapping("/success/{id}")
    public Result<Payment> paymentSuccess(@PathVariable("id") Long id) {
        String msg=this.paymentService.paymentSuccess(id);
        return new Result(200,true,msg+"，服务处理来自:"+serverPort);
    }

    @GetMapping("/fail/{id}")
    public String paymentFail(@PathVariable("id") Long id) {
        return paymentService.paymentFail(id);

    }

    @GetMapping("/rd/{id}")
    public Result<Payment> paymentRd(@PathVariable("id") Long id) {
        String msg=this.paymentService.rd(id);
        return new Result(200,true,msg+"，服务处理来自:"+serverPort);
    }

}